/*
 * AbstractSkyBox.java
 * 
 * Created on 2008-04-19, 11:39:19
 */

package planesimulator.utils.skybox;

import planesimulator.utils.SkyBoxContainer;
import java.net.URL;
import java.util.logging.Logger;
import planesimulator.game.MainGame;

/**
 * Skybox adder singleton.
 *
 * @author Mateusz 'm4linka' Malinowski (m4linka@gmail.com)
 */
public class SkyBoxAdder {

    /** Textures path prefix */
  private final static String TEXTURE_PREFIX = "planesimulator/data/skybox/";
  
  /** Textures' names */
  private final static String TEXTURE_NAMES[] =
      {"north", "south", "east", "west", "up", "down"};
  
  
  /** Constructor */
  private SkyBoxAdder() {}
  
  
  /**
   * Adds skybox to the specified container
   * 
   * @param container container where this sky box will be stored
   * @param skybox_name skybox's name
   */
  public final static void addToContainer(
      final SkyBoxContainer container, final String skybox_name) {
    
    URL textures_path[] = new URL[6];
    
    // prepare textures paths
    for(int i = 0; i < TEXTURE_NAMES.length; i++) {
      final URL resource_name = Thread.currentThread().getContextClassLoader()
          .getResource(TEXTURE_PREFIX + skybox_name + "/" 
              + TEXTURE_NAMES[i] + ".jpg");
      
      textures_path[i] = resource_name;
      Logger.getLogger(MainGame.class.getName()).info("Load texture from: " + 
          resource_name);
    } 
    
    container.addSkybox(skybox_name, textures_path);
  }
  
}
